package com.zixi.ai.common.utils.uuid;


import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.IdUtil;

/**
 * @author wfg
 */
public class SnowflakeUtil {
    public static Long getSnowflake() {
        String ip = NetUtil.getLocalhostStr();
        // 获取工作ID
        int workId = ip.hashCode() & 0x1F;
        String hostname = NetUtil.getLocalHostName();
        // 获取数据中心ID
        int datacenterId = hostname.hashCode() & 0x1F;
        return IdUtil.getSnowflake(workId, datacenterId).nextId();
    }
}
